//
//  ViewController.swift
//  TableViewCollectionView
//
//  Created by lete on 2020/4/24.
//  Copyright © 2020 lete. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        self.navigationItem.title = "dd"
        
        self.view.backgroundColor = UIColor.white
        
        setupUI()
        
    }
    
    
    func setupUI() {
        //创建tableview按钮
        let jumpTableviewBtn  = UIButton(type: UIButton.ButtonType.custom)
        jumpTableviewBtn.setTitle("跳转tableview", for: .normal)
        jumpTableviewBtn.frame = CGRect(x: 50, y: 150, width: 150, height: 100)
        jumpTableviewBtn.backgroundColor = UIColor(red: 50/255, green: 33/255, blue: 90/255, alpha: 1)
        jumpTableviewBtn.setTitleColor(UIColor.white, for: .normal)
        //按钮绑定事件，点击时执行
        jumpTableviewBtn.addTarget(self, action:  #selector(pageTableViewJump), for: .touchDown)
        
        self.view.addSubview(jumpTableviewBtn)
        
        
        //创建按钮
        let jumpcollBtn  = UIButton(type: UIButton.ButtonType.custom)
                jumpcollBtn.setTitle("跳转coll", for: .normal)
                jumpcollBtn.frame = CGRect(x: 50, y: 350, width: 150, height: 100)
                jumpcollBtn.backgroundColor = UIColor(red: 50/255, green: 123/255, blue: 203/255, alpha: 1)
                jumpcollBtn.setTitleColor(UIColor.white, for: .normal)
                //按钮绑定事件，点击时执行
                jumpcollBtn.addTarget(self, action:  #selector(pageCollJump), for: .touchDown)
                
                self.view.addSubview(jumpcollBtn)
        
    }
    
    //实现按钮方法
    @objc func pageTableViewJump() {
        //跳转
        let nextVc = MyTableViewController()
        //跳转
//        self.present(nextVc, animated: true, completion: nil)
        self.navigationController?.pushViewController(nextVc, animated: true)
        
    }
    
    @objc func pageCollJump() {
          //跳转
                 let nextVc = MyCollectionViewController()
                 //跳转
         //        self.present(nextVc, animated: true, completion: nil)
                 self.navigationController?.pushViewController(nextVc, animated: true)
       }
    
}

